﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DBUtility;
using MySql.Data.MySqlClient;

namespace DAL
{
    public class DTaxiCDMA
    {



        public bool ExistsDeviceNumber(string deviceNumber)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from tTaxiCDMA");
            strSql.Append(" where DeviceNumber=@DeviceNumber");
            MySqlParameter[] parameters = {
					new MySqlParameter("@DeviceNumber", MySqlDbType.VarChar,20)
             };
            parameters[0].Value = deviceNumber;

            return DbHelperMySQL.Exists(strSql.ToString(), parameters);
        }

        public bool ExistsPhoneNumber(string phoneNumber)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from tTaxiCDMA");
            strSql.Append(" where PhoneNumberDay='");
            strSql.Append(phoneNumber);
            strSql.Append("' or PhoneNumberNight='");
            strSql.Append(phoneNumber);
            strSql.Append("'");
            return DbHelperMySQL.Exists(strSql.ToString());
        }
         
        #region  Method

        

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.TaxiCdmaInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into tTaxiCDMA(");
            strSql.Append("DeviceNumber,TaxiNo,TaxiType,SpeedOut,SpeedOutIsOpen,");
            strSql.Append("StopTimeOut,StopTimeOutIsOpen,FatigueDrivingTime,FatigueDrivingIsOpen,");
            strSql.Append("CompanyId,PhoneNumberDay,PhoneNumberNight,DriverDay,DriverNight,Remark,SIM)");
            strSql.Append(" values (");
            strSql.Append("@DeviceNumber,@TaxiNo,@TaxiType,@SpeedOut,@SpeedOutIsOpen,");
            strSql.Append("@StopTimeOut,@StopTimeOutIsOpen,@FatigueDrivingTime,@FatigueDrivingIsOpen,");
            strSql.Append("@CompanyId,@PhoneNumberDay,@PhoneNumberNight,@DriverDay,@DriverNight,@Remark,@SIM)");
            MySqlParameter[] parameters = {
					new MySqlParameter("@DeviceNumber", MySqlDbType.VarChar,25),
					new MySqlParameter("@TaxiNo", MySqlDbType.VarChar,45),
					new MySqlParameter("@TaxiType", MySqlDbType.VarChar,45),
					new MySqlParameter("@SpeedOut", MySqlDbType.VarChar,6),
					new MySqlParameter("@SpeedOutIsOpen", MySqlDbType.VarChar,2),
					new MySqlParameter("@StopTimeOut", MySqlDbType.VarChar,6),
                    new MySqlParameter("@StopTimeOutIsOpen", MySqlDbType.VarChar,2),
                    new MySqlParameter("@FatigueDrivingTime", MySqlDbType.VarChar,6),
                    new MySqlParameter("@FatigueDrivingIsOpen", MySqlDbType.VarChar,2),                     
                    new MySqlParameter("@CompanyId", MySqlDbType.Int32),
                    new MySqlParameter("@PhoneNumberDay", MySqlDbType.VarChar,20),
                    new MySqlParameter("@PhoneNumberNight", MySqlDbType.VarChar,20),
                    new MySqlParameter("@DriverDay", MySqlDbType.VarChar,20),
                    new MySqlParameter("@DriverNight", MySqlDbType.VarChar,20),
                    new MySqlParameter("@Remark", MySqlDbType.Text),
                    new MySqlParameter("@SIM", MySqlDbType.VarChar,15)};
            parameters[0].Value = model.DeviceNumber;
            parameters[1].Value = model.TaxiNo;
            parameters[2].Value = model.TaxiType;
            parameters[3].Value = model.SpeedOut;
            parameters[4].Value = model.SpeedOutIsOpen;
            parameters[5].Value = model.StopTimeOut;
            parameters[6].Value = model.StopTimeOutIsOpen;
            parameters[7].Value = model.FatigueDrivingTime;
            parameters[8].Value = model.FatigueDrivingIsOpen; 
            parameters[9].Value = model.CompanyId;
            parameters[10].Value = model.PhoneNumberDay;
            parameters[11].Value = model.PhoneNumberNight;
            parameters[12].Value = model.DriverDay;
            parameters[13].Value = model.DriverNight;
            parameters[14].Value = model.Remark;
            parameters[15].Value = model.SIM;
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.TaxiCdmaInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update tTaxiCDMA set ");
            strSql.Append("DeviceNumber=@DeviceNumber,");
            strSql.Append("TaxiNo=@TaxiNo,");
            strSql.Append("TaxiType=@TaxiType,");            
            strSql.Append("CompanyId=@CompanyId,");
            strSql.Append("PhoneNumberDay=@PhoneNumberDay,");
            strSql.Append("PhoneNumberNight=@PhoneNumberNight,");
            strSql.Append("DriverDay=@DriverDay,");
            strSql.Append("DriverNight=@DriverNight,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("SIM=@SIM"); 
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters = {
					new MySqlParameter("@DeviceNumber", MySqlDbType.VarChar,25),
					new MySqlParameter("@TaxiNo", MySqlDbType.VarChar,45),
					new MySqlParameter("@TaxiType", MySqlDbType.VarChar,45),                
                    new MySqlParameter("@CompanyId", MySqlDbType.Int32),
                    new MySqlParameter("@PhoneNumberDay", MySqlDbType.VarChar,20),
                    new MySqlParameter("@PhoneNumberNight", MySqlDbType.VarChar,20),
                    new MySqlParameter("@DriverDay", MySqlDbType.VarChar,20),
                    new MySqlParameter("@DriverNight", MySqlDbType.VarChar,20),
                    new MySqlParameter("@Remark", MySqlDbType.Text),
                    new MySqlParameter("@SIM", MySqlDbType.VarChar,15),
                    new MySqlParameter("@id", MySqlDbType.Int32)};
            parameters[0].Value = model.DeviceNumber;
            parameters[1].Value = model.TaxiNo;
            parameters[2].Value = model.TaxiType; 
            parameters[3].Value = model.CompanyId;
            parameters[4].Value = model.PhoneNumberDay;
            parameters[5].Value = model.PhoneNumberNight;
            parameters[6].Value = model.DriverDay;
            parameters[7].Value = model.DriverNight;
            parameters[8].Value = model.Remark;
            parameters[9].Value = model.SIM; 
            parameters[10].Value = model.Id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
  
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tTaxiCDMA ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters = {
					new MySqlParameter("@id", MySqlDbType.Int32)
};
            parameters[0].Value = id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tTaxiCDMA ");
            strSql.Append(" where id in (" + idlist + ")  ");
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.TaxiCdmaInfo GetModelById(int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from tTaxiCDMA ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters = {
					new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Model.TaxiCdmaInfo model = new Model.TaxiCdmaInfo();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DeviceNumber"] != null && ds.Tables[0].Rows[0]["DeviceNumber"].ToString() != "")
                {
                    model.DeviceNumber = ds.Tables[0].Rows[0]["DeviceNumber"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiNo"] != null && ds.Tables[0].Rows[0]["TaxiNo"].ToString() != "")
                {
                    model.TaxiNo = ds.Tables[0].Rows[0]["TaxiNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiType"] != null && ds.Tables[0].Rows[0]["TaxiType"].ToString() != "")
                {
                    model.TaxiType = ds.Tables[0].Rows[0]["TaxiType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SpeedOut"] != null && ds.Tables[0].Rows[0]["SpeedOut"].ToString() != "")
                {
                    model.SpeedOut = int.Parse(ds.Tables[0].Rows[0]["SpeedOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpeedOutIsOpen"] != null && ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString() != "")
                {
                    model.SpeedOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOut"] != null && ds.Tables[0].Rows[0]["StopTimeOut"].ToString() != "")
                {
                    model.StopTimeOut = int.Parse(ds.Tables[0].Rows[0]["StopTimeOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOutIsOpen"] != null && ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString() != "")
                {
                    model.StopTimeOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingTime"] != null && ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString() != "")
                {
                    model.FatigueDrivingTime = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"] != null && ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString() != "")
                {
                    model.FatigueDrivingIsOpen = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString());
                } 
                if (ds.Tables[0].Rows[0]["CompanyId"] != null && ds.Tables[0].Rows[0]["CompanyId"].ToString() != "")
                {
                    model.CompanyId = int.Parse(ds.Tables[0].Rows[0]["CompanyId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberDay"] != null && ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString() != "")
                {
                    model.PhoneNumberDay = ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberNight"] != null && ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString() != "")
                {
                    model.PhoneNumberNight = ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverDay"] != null && ds.Tables[0].Rows[0]["DriverDay"].ToString() != "")
                {
                    model.DriverDay = ds.Tables[0].Rows[0]["DriverDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverNight"] != null && ds.Tables[0].Rows[0]["DriverNight"].ToString() != "")
                {
                    model.DriverNight = ds.Tables[0].Rows[0]["DriverNight"].ToString();
                } 
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SIM"] != null && ds.Tables[0].Rows[0]["SIM"].ToString() != "")
                {
                    model.SIM = ds.Tables[0].Rows[0]["SIM"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.TaxiCdmaInfo GetModelByDeviceNumber(string deviceNumber)
        {
           

            //StringBuilder strSql = new StringBuilder();
            //strSql.Append("select * from tTaxiCDMA ");
            //strSql.Append(" where DeviceNumber=@DeviceNumber");
            //MySqlParameter[] parameters = {
            //        new MySqlParameter("@DeviceNumber", MySqlDbType.Int32)
            //};
            //parameters[0].Value = deviceNumber;
            //DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            DataSet ds = GetList(" DeviceNumber='" + deviceNumber + "'");
            Model.TaxiCdmaInfo model = new Model.TaxiCdmaInfo();                       
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DeviceNumber"] != null && ds.Tables[0].Rows[0]["DeviceNumber"].ToString() != "")
                {
                    model.DeviceNumber = ds.Tables[0].Rows[0]["DeviceNumber"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiNo"] != null && ds.Tables[0].Rows[0]["TaxiNo"].ToString() != "")
                {
                    model.TaxiNo = ds.Tables[0].Rows[0]["TaxiNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiType"] != null && ds.Tables[0].Rows[0]["TaxiType"].ToString() != "")
                {
                    model.TaxiType = ds.Tables[0].Rows[0]["TaxiType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SpeedOut"] != null && ds.Tables[0].Rows[0]["SpeedOut"].ToString() != "")
                {
                    model.SpeedOut = int.Parse(ds.Tables[0].Rows[0]["SpeedOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpeedOutIsOpen"] != null && ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString() != "")
                {
                    model.SpeedOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOut"] != null && ds.Tables[0].Rows[0]["StopTimeOut"].ToString() != "")
                {
                    model.StopTimeOut = int.Parse(ds.Tables[0].Rows[0]["StopTimeOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOutIsOpen"] != null && ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString() != "")
                {
                    model.StopTimeOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingTime"] != null && ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString() != "")
                {
                    model.FatigueDrivingTime = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"] != null && ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString() != "")
                {
                    model.FatigueDrivingIsOpen = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString());
                } 
                if (ds.Tables[0].Rows[0]["CompanyId"] != null && ds.Tables[0].Rows[0]["CompanyId"].ToString() != "")
                {
                    model.CompanyId = int.Parse(ds.Tables[0].Rows[0]["CompanyId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberDay"] != null && ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString() != "")
                {
                    model.PhoneNumberDay = ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberNight"] != null && ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString() != "")
                {
                    model.PhoneNumberNight = ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverDay"] != null && ds.Tables[0].Rows[0]["DriverDay"].ToString() != "")
                {
                    model.DriverDay = ds.Tables[0].Rows[0]["DriverDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverNight"] != null && ds.Tables[0].Rows[0]["DriverNight"].ToString() != "")
                {
                    model.DriverNight = ds.Tables[0].Rows[0]["DriverNight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CompanyName"] != null && ds.Tables[0].Rows[0]["CompanyName"].ToString() != "")
                {
                    model.CompanyName = ds.Tables[0].Rows[0]["CompanyName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SIM"] != null && ds.Tables[0].Rows[0]["SIM"].ToString() != "")
                {
                    model.SIM = ds.Tables[0].Rows[0]["SIM"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.TaxiCdmaInfo GetModelByPhoneNumber(string phoneNumber)
        {
            string strWhere = " t.PhoneNumberDay='" + phoneNumber + "' or t.PhoneNumberNight='"+phoneNumber+"'";
            DataSet ds = GetList(strWhere);
            Model.TaxiCdmaInfo model = new Model.TaxiCdmaInfo();
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DeviceNumber"] != null && ds.Tables[0].Rows[0]["DeviceNumber"].ToString() != "")
                {
                    model.DeviceNumber = ds.Tables[0].Rows[0]["DeviceNumber"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiNo"] != null && ds.Tables[0].Rows[0]["TaxiNo"].ToString() != "")
                {
                    model.TaxiNo = ds.Tables[0].Rows[0]["TaxiNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TaxiType"] != null && ds.Tables[0].Rows[0]["TaxiType"].ToString() != "")
                {
                    model.TaxiType = ds.Tables[0].Rows[0]["TaxiType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SpeedOut"] != null && ds.Tables[0].Rows[0]["SpeedOut"].ToString() != "")
                {
                    model.SpeedOut = int.Parse(ds.Tables[0].Rows[0]["SpeedOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpeedOutIsOpen"] != null && ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString() != "")
                {
                    model.SpeedOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["SpeedOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOut"] != null && ds.Tables[0].Rows[0]["StopTimeOut"].ToString() != "")
                {
                    model.StopTimeOut = int.Parse(ds.Tables[0].Rows[0]["StopTimeOut"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StopTimeOutIsOpen"] != null && ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString() != "")
                {
                    model.StopTimeOutIsOpen = int.Parse(ds.Tables[0].Rows[0]["StopTimeOutIsOpen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingTime"] != null && ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString() != "")
                {
                    model.FatigueDrivingTime = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"] != null && ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString() != "")
                {
                    model.FatigueDrivingIsOpen = int.Parse(ds.Tables[0].Rows[0]["FatigueDrivingIsOpen"].ToString());
                }
                
                if (ds.Tables[0].Rows[0]["CompanyId"] != null && ds.Tables[0].Rows[0]["CompanyId"].ToString() != "")
                {
                    model.CompanyId = int.Parse(ds.Tables[0].Rows[0]["CompanyId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberDay"] != null && ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString() != "")
                {
                    model.PhoneNumberDay = ds.Tables[0].Rows[0]["PhoneNumberDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PhoneNumberNight"] != null && ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString() != "")
                {
                    model.PhoneNumberNight = ds.Tables[0].Rows[0]["PhoneNumberNight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverDay"] != null && ds.Tables[0].Rows[0]["DriverDay"].ToString() != "")
                {
                    model.DriverDay = ds.Tables[0].Rows[0]["DriverDay"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DriverNight"] != null && ds.Tables[0].Rows[0]["DriverNight"].ToString() != "")
                {
                    model.DriverNight = ds.Tables[0].Rows[0]["DriverNight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CompanyName"] != null && ds.Tables[0].Rows[0]["CompanyName"].ToString() != "")
                {
                    model.CompanyName = ds.Tables[0].Rows[0]["CompanyName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SIM"] != null && ds.Tables[0].Rows[0]["SIM"].ToString() != "")
                {
                    model.SIM = ds.Tables[0].Rows[0]["SIM"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        { 
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT t.Id,t.DeviceNumber,t.TaxiNo,t.TaxiType,t.SpeedOut,t.SpeedOutIsOpen,");
            strSql.Append("t.StopTimeOut,t.StopTimeOutIsOpen,t.FatigueDrivingTime,t.FatigueDrivingIsOpen,");
            strSql.Append("t.CompanyId,t.PhoneNumberDay,t.PhoneNumberNight,");
            strSql.Append("t.DriverDay,t.DriverNight,t.Remark,t.SIM,tb.CompanyName from tTaxiCDMA t ");
            strSql.Append("left join  tcompany tb on t.CompanyId=tb.id "); 
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by t.id asc ");
            return DbHelperMySQL.Query(strSql.ToString());
        }

         
        #endregion  Method
    }
}
